language: php

php:
  - '7.4'

dist: trusty

sudo: false

env:
  global:
    - setup=stable

before_install:
  - travis_retry composer self-update

install:
  - if [[ $setup = 'stable' ]]; then COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update --prefer-dist --prefer-stable --no-interaction; fi
  - if [[ $setup = 'normal' ]]; then COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update --prefer-dist --no-interaction --prefer-stable; fi

before_script:
  - cp .env.travis .env
  - mysql -e 'create database apiato_db;'
  - php artisan key:generate
  - php artisan migrate --seed
  - php artisan passport:install

script: vendor/bin/phpunit

cache:
  directories:
    - $HOME/.composer/cache

after_failure:
  - echo --------------- Begin > Laravel.log ---------------
  - cat storage/logs/laravel.log
  - echo --------------- End   > Laravel.log ---------------

after_success:
  - php artisan -V
